/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package netfone;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author bruno
 */
class User {
    private List<Contact> contacts = new ArrayList<Contact>();
    private String name;
    
    

   public User(String name){
       this.name = name;
   }
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    @Override
    public String toString(){
        return this.name;
    }

    public List<Contact> getContacts() {
        return contacts;
    }

   /* public void setContacts(List<Contact> contacts) {
        this.contacts = contacts;
    }*/
    
    public boolean equals(Object o ){
        if (o instanceof User){
            User u= (User)o;
            return u.getName().equals(this.getName());
        }
        else{
            return false;
        } 
            
    }
    
    public int hashCode(){
       return this.getName().hashCode(); 
    }
    
    public void addContact(Contact c){
        contacts.add(c);
        c.addUser(this);
    }
    
    public void removeContact(Contact c){
        contacts.remove(c);
        c.removeUser(this);
    }

}
